package com.d3works.apps.supplychain.service.batch;

import com.d3works.apps.base.db.repo.BatchRepository;
import com.d3works.apps.base.exceptions.BaseExceptionMessage;
import com.d3works.apps.base.service.administration.AbstractBatch;
import com.d3works.apps.supplychain.exception.SupplychainExceptionMessage;
import com.d3works.i18n.I18n;

public abstract class BatchOrderInvoicing extends AbstractBatch {

  @Override
  protected void stop() {
    StringBuilder sb = new StringBuilder();
    sb.append(I18n.get(SupplychainExceptionMessage.BATCH_ORDER_INVOICING_REPORT));
    sb.append(
        String.format(
            I18n.get(
                SupplychainExceptionMessage.BATCH_ORDER_INVOICING_DONE_SINGULAR,
                SupplychainExceptionMessage.BATCH_ORDER_INVOICING_DONE_PLURAL,
                batch.getDone()),
            batch.getDone()));
    sb.append(
        String.format(
            I18n.get(
                BaseExceptionMessage.ABSTRACT_BATCH_ANOMALY_SINGULAR,
                BaseExceptionMessage.ABSTRACT_BATCH_ANOMALY_PLURAL,
                batch.getAnomaly()),
            batch.getAnomaly()));
    addComment(sb.toString());
    super.stop();
  }

  protected void setBatchTypeSelect() {
    this.batch.setBatchTypeSelect(BatchRepository.BATCH_TYPE_SUPPLYCHAIN_BATCH);
  }
}
